<!DOCTYPE html>
<html>
<head>
	<title></title>
	<meta charset="utf-8">
	<link rel="stylesheet" type="text/css" href="/bower_components/bootstrap/dist/css/bootstrap.css">
	<link rel="stylesheet" type="text/css" href="/stylesheets/admin.css">
	<script type="text/javascript" src="//cdn.bootcss.com/jquery/1.12.2/jquery.js"></script>
	<script type="text/javascript" src="/bower_components/bootstrap/dist/js/bootstrap.js"></script>
	<script type="text/javascript" src="/bower_components/upload-jquery/jquery.upload.js"></script>
</head>
<body>
	<div class="container">
		<div class="row">
			<div class="col-xs-8 col-xs-offset-2">
				<div class="page-header">
					<h3>修改文章<a href="/admin/articleLists" class="pull-right"><返回</a></h3>
				</div>
				<form action="/admin/reverse" method="post">
					<input type="hidden" name="id" value="<%=rows.id%>">
					<div class="form-group">
						<label>文章标题：</label>
						<input type="text" name="title" class="form-control" value="<%= rows.title%>">
					</div>
					<div class="form-group">
						<label>图片地址</label>
						<div class="row">
							<div class="col-xs-10">
								<img id="image_preview" />
								<input id="image" type="hidden" name="images" class="form-control" value="<%= rows.img%>">
							</div>
							<div class="col-xs-2">
								<!-- 模态框上传按钮 -->
								<!-- <button type="button" class="btn btn-primary pull-right" data-toggle="modal" data-target="#myModal">修改图片</button> -->



								<!-- jQuery插件上传按钮 -->
								 <button type="button" class="btn btn-primary pull-right" onclick="doUpload()">点击上传</button>

							</div>
						</div>
						
						
					</div>

					<div class="form-group">
						<label>分类id：</label>
						<select name="cata_id" class="form-control">
							<% for(var i=0;i<catalogs.length;i++){ %>
							<option <% if(rows.cata_id==catalogs[i].id){%> selected=selected <%}%> value="<%= catalogs[i].id%>"><%= catalogs[i].name%></option>
							<% } %>
						</select>

					</div>

					<div class="form-group">
						<label>文章内容：</label>
						<textarea class="form-control" name="content"><%= rows.content%></textarea>
					</div>
						<button type="submit" class="btn btn-success">确认修改</button>
				</form>



				


				<!-- iframe+模态框上传文件 -->
				<!-- Modal -->
			<!-- 	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
					<div class="modal-dialog" role="document">
						<div class="modal-content">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
								<h4 class="modal-title" id="myModalLabel">修改图片</h4>
							</div>
							<form method="post" action="/admin/uploadFile" enctype="multipart/form-data" name="fileForm" target="fileUpload">
								<div class="modal-body">								
									<input type="file" class="fileInput" name="fileInput">				
									<iframe name="fileUpload" class="hidden"></iframe>
								</div>
								<div class="modal-footer">
									<button type="submit" class="btn btn-primary">上传</button>
								</div>
							</form>
						</div>
					</div>
				</div> -->




			</div>
		</div>
		
	</div>
</body>

 <script type="text/javascript">
 		/*iframe+模态框上传文件*/
		/*function changePath(path){
			$("#image").val(path)
		
	}*/


	/*jQuery插件上传文件*/
	function doUpload() {
	// 上传方法
	$.upload({
			// 上传地址
			url: '/admin/uploadFile', 
			// 文件域名字
			fileName: 'fileInput', 
			// 其他表单数据
			params: {},
			// 上传完成后, 返回json, text
			dataType: 'text',
			// 上传之前回调,return true表示可继续上传
			onSend: function() {
					return true;
			},
			// 上传之后回调
			onComplate: function(data) {
					$('#image').val(data);
					$('#image_preview').attr("src",data);
			}
	});
}

</script>
</html>